<?php 

namespace app\controller\bossManager;

use app\service\SendConfigService;
use app\validate\SendConfigValidate;
use app\validate\PageValidate;
use share\utils\Helper;

class SendConfigController extends WebBossController{

    public function initValidate(){
        $this->validate = new SendConfigValidate();
    }

    public function list_action(){
        $param = $this->request->param();
        $page = $this->check('pageInfo',null,(new PageValidate()));
        $data = SendConfigService::getListInfo($param,$page);
        $total = SendConfigService::getListCountInfo($param);
        return self::ok(self::formatPageData($page,$total,$data));
    }

    public function set_action(){
        $input = $this->check();
        $res = SendConfigService::setConfig($input);
        return self::ok($res);
    }

    public function del_action(){
        $input = $this->check();
        $res = SendConfigService::del($input['id']);
        return self::ok($res);
    }

    public function simple_all_action(){      
        $data = SendConfigService::getAllByFilter([]);        
        return self::ok(Helper::pickArrayColumn($data,['id','name','appid','type']));
    }
}
